/*
 *   Copyright 2012, Thomas Kerber
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
package milk.jpatch;

import java.io.File;
import java.io.IOException;


// NOTE: this is NOT a java "Serializable", as the class itself determines
// where and how to write itself into the Directory structure.
/**
 * Denotes a class which can be serialized - not into a file, but into a
 * directory structure.
 * 
 * The following methods are static, but should be implemented nontheless.
 * 
 * <code>
 * public static boolean canDeserializeAt(File root, String name);
 * public static DirectorySerializable deserializeAt(File root,
 *         String name) throws IOException;
 * </code>
 * 
 * Classes which implement this do not, repeat do NOT implement java's
 * serializable.
 * @author Thomas Kerber
 * @version 1.0.0
 */
public interface DirectorySerializable{
    
    /**
     * Writes object into a directory.
     * @param root The directory to write into.
     * @throws IOException
     */
    public void serialize(File root) throws IOException;
    
    /**
     * 
     * @param root The directory to check from.
     * @param name The name of the file relative to the directory to check.
     * @return Whether or not the file denoted by root and name can be
     *         deserialized by this class.
     */
    // public static boolean canDeserializeAt(File root, String name);
    /**
     * 
     * @param root The directory to check from.
     * @param name The name of the file relative to the directory to check.
     * @return The deserialized object.
     * @throws IOException
     */
    // public static DirectorySerializable deserializeAt(File root,
    //         String name) throws IOException;
    
}
